<template>
	<form @submit="form.submit($event,success)" data-action="/api/staff/save" v-if="!isCompleted">
		
		<view class="fixAuto bb middle">
			<view class="w80">
				姓名
			</view>
			<view>
				<input type="text" name="name|姓名" maxlength="20" placeholder="请输入真实姓名">
			</view>
		</view>
		
		<view class="fixAuto bb middle">
			<view class="w80">
				身份证号
			</view>
			<view>
				<input type="idcard" name="idcard|身份证号|idcard" placeholder="请输入身份证号码">
			</view>
		</view>
		
		<view class="fixAuto bb middle">
			<view class="w80">
				手机号码
			</view>
			<view>
				<input type="number" name="mobile|手机号码|mobile" placeholder="请输入手机号码">
			</view>
		</view>
		
		<view class="fixAuto bb middle ptb20" @tap="toUploadImage('license')">
			<view class="w80">
				执业证书
			</view>
			<view class="item">
				<view class="flex rt ">
					<view style="width: 50px;">
						<view class="square shadow rds4" v-if="data.license">
							<image :src="data.license" class="rds4 bd" mode="aspectFill"></image>
						</view>
						<view class="square rds4 grayBg " v-else>
							<view class="bd rds4  fz24 flex ct">
								<view class="sIcon-photoFill grey"></view>
							</view>
						</view>
						<input type="text" maxlength="-1" name="license|执业证书" :value="data.license" style="display: none;"/>
					</view>
					<view class="sIcon-arrowRight pl10 gray"></view>
				</view>
			</view>
		</view>
		
		<view class="plr100 pd30">
			<button form-type="submit" class="btn block rds23">
				确认保存
			</button>
		</view>
		
	</form>
	
	<block v-else>
		
		<result title="等待审核" desc="运维人员资料已提交，请耐心等待审核\n审核通过后可使用手机号码登录系统" icon="sIcon-clockFill" iconColor="#3385ff"></result>
		
	</block>
	
</template>

<script>
	import {Qiniu} from "../../common/upload.js" ;
	export default {
		data() {
			return {
				data : { license : "" },
				isCompleted : false ,
				qiniu : new Qiniu()
			}
		},
		
		onLoad(param) {
			
		},
		
		methods: {
			
			toUploadImage:function(key){
				var sourceTypes = ["album", "camera"];
				uni.showActionSheet({
					itemList:["从相册选择","从相机拍照"],
					success : res => {
						uni.chooseImage({
							sourceType:[sourceTypes[res.tapIndex]],
							count:1,
							success: res =>{
								uni.showNavigationBarLoading();
								this.qiniu.upload(res.tempFilePaths[0] , res =>{
									this.$set(this.data,key,res);
									uni.hideNavigationBarLoading();
								});
							}
						});
					}
				});
			},
			
			success:function(e){
				this.isCompleted = true ;
			}
		}
	}
</script>

<style>
page{
	background-color: #fff;
}
.fixAuto{
	padding: 30upx 10upx;
}
</style>
